#include<iostream>
#include"Player.h"
using namespace std;


Player::Player():availableResources(){
	playerName		= "none";
	playerColor		= RED;
	victoryPoints	= 0;
	nmbOfRoads		= 0;
	nmbOfSettlements = 0;
	nmbOfCities		= 0;
	for(int i=0; i<9; i++){
		availableDevelopments.setNmbOfDev(i, 0);
		onTableDevelopments.setNmbOfDev(i,0);
	}
}

Player::Player(string theName, color theColor): availableResources(){
	victoryPoints	= 0;
	nmbOfRoads		= 15;
	nmbOfSettlements = 5;
	nmbOfCities		= 4;
	playerName		= theName;
	playerColor		= theColor;
	for(int i=0; i<9; i++){
		availableDevelopments.setNmbOfDev(i, 0);
		onTableDevelopments.setNmbOfDev(i,0);
	}
}

int Player::getVictoryPoints(){
	return victoryPoints;
}

int Player::getNmbOfRoads(){
	return nmbOfRoads;
}

int Player::getNmbOfSettlements(){
	return nmbOfSettlements;
}

int Player::getNmbOfCities(){
	return nmbOfCities;
}

string Player::getName(){
	return playerName;
}

color Player::getColor(){
	return playerColor;
}

ResourceSet Player::getResources(){
	return availableResources;
}

DevelopmentTray Player::getDevelopments(){
	return availableDevelopments;
}

DevelopmentTray Player::getOnTableDevelopments(){
	return onTableDevelopments;
}

void Player::setVictoryPoints(int theNumber){
	victoryPoints = theNumber;
}

void Player::setNmbOfRoads(int theNumber){
	nmbOfRoads = theNumber;
}

void Player::setNmbOfSettlements(int theNumber){
	nmbOfSettlements = theNumber;
}

void Player::setNmbOfCities(int theNumber){
	nmbOfCities = theNumber;
}

void Player::setResources(ResourceSet newAvailableResources){
	availableResources = newAvailableResources;
}

void Player::setDevelopments(int arrayIndex, int nmb){
	availableDevelopments.setNmbOfDev(arrayIndex, nmb);
}

void Player::setOnTableDevelopments(int arrayIndex, int nmb){
	onTableDevelopments.setNmbOfDev(arrayIndex, nmb);
}

void Player::printPlayer(){
	string stringColor;
	switch(playerColor){
	case 0:
		stringColor = "red";
		break;
	case 1:
		stringColor = "green";
		break;
	case 2:
		stringColor = "blue";
		break;
	case 3:
		stringColor = "yellow";
		break;
	default:
		stringColor = "undefined color";
	}
	cout<<"name: "<<playerName<<", color: "<<stringColor<<", victory points: "<<victoryPoints<<endl;
	availableResources.printResourceSet();
	cout<<"in hand ";
	availableDevelopments.printDevelopmentTray();
	cout<<"on table ";
	onTableDevelopments.printDevelopmentTray();
	cout<<"Available to buy roads: "<<nmbOfRoads<<", settlements: "<<nmbOfSettlements<<", cities: "<< nmbOfCities<<endl;
}
